<?php
require_once("../config.php");
//if(!isset($_SESSION['admin_user'])) header("location:index.php");
require_once(CONSTANT."alltype.php");
page_constant("admin");

$tpl->assign("type_main",$type_product_c);
$tpl->assign("type_clothing",$type_clothing_c);
$tpl->assign("type_watch",$type_watch_c);
$tpl->assign("type_brand",$type_brand_c);
$tpl->assign("type_bag",$type_bag_c);
$tpl->assign("type_shoe",$type_shoe_c);
$tpl->assign("type_jewelry",$type_jewelry_c);
$tpl->assign("type_glass",$type_glass_c);
$tpl->assign("type_accessory",$type_accessory_c);

if(isset($_POST['belongto']) and !empty($_POST['typename']))
{
	$post_typename=trim($_POST['typename']);
	$re=$dsql->getone("select id from alltype where typename = '$post_typename'");
	if(!empty($re))
		$tpl->assign('error','属性已经存在请勿添加');
	else
	{
		$uid=new UID();
		$data=array('id'=>'',
		'typename'=>trim($_POST['typename']),
		'belongto'=>$_POST['belongto']);
		$uid->insert("alltype",$data);					
	}
}
if(isset($_GET['userid']))
{
	$uid=new UID();
	$data=array("status"=>$_GET['turn']);
	$condition="id = ".$_GET['userid'];
	$uid->update("backuser",$data,$condition);
}
if(isset($_GET['belongto']))
	$belongto=$_GET['belongto'];
else
	$belongto="season";
$dsql->SetQuery("select id,typename from alltype where belongto = '$belongto'");
$dsql->Execute();
while($rs=$dsql->GetArray())
{
		$temp[]=$rs;
		//$temp2[]=$rs['id'];
}
$tpl->assign("ceil",$temp);


$dsql->SetQuery("select * from backuser");
$dsql->Execute();
while($row=$dsql->GetArray())
	$user[]=$row;
$tpl->assign("user",$user);

$dsql->SetQuery("select * from backuser where id in (select distinct(userid) from pic)");
$dsql->Execute();
while($row=$dsql->GetArray())
	$usercheck[]=$row;
$tpl->assign("usercheck",$usercheck);

$tpl->display("admin_type.tpl");
?>